package de.mmis.core.base.gui;

import de.mmis.core.base.device.Device;
import de.mmis.core.base.event.Event;
import de.mmis.core.base.event.Observable;
import de.mmis.core.base.event.Observer;
import de.mmis.core.base.gui.GUIComponent.GUIEvent;

/**
 * general interface for all GUI components representing and/or controlling a
 * {@link Device}. It is presumed that it has a parameterless constructor that
 * does no additional memory allocation. Object instantiation should be done in
 * the initialize method.
 * 
 * @author Christian Koch
 * 
 * @param <D>
 *            type of device that is represented and/or controlled
 */
public interface GUIComponent<D> extends Observer<GUIEvent>,
		Observable<GUIEvent> {
	public interface GUIEvent extends Event {
		// nothing
	}

	/**
	 * @return display name of this gui component
	 */
	public abstract String getDisplayName(String languageCode);

	/**
	 * initialize the GUI component for being used with an object of given type.
	 * All member instantiation should be done here instead of inside the
	 * constructor. This method should be called exactly once, prior to all
	 * update and customization info calls.
	 * 
	 * @param clazz
	 *            type of object that will be used
	 * @param device
	 *            device to be used in this GUI component
	 */
	public void initialize(Class<?> clazz, Device<D> device,
			ClassLoader classLoader);

	/**
	 * @return the priority of this component. The components of a device will
	 *         be ordered, so that the component with the highest priority will
	 *         be the first in the list. Reference values: the default component
	 *         has priority 0, a single specialized component should have
	 *         priority 100.
	 */
	public long getPriority();
}
